﻿<?php
class Form_Ajoutervip extends Zend_Form
{
	public function init(){
		$this->setMethod('post');
		$this->setName('Ajouter VIP\'s');
//nom		
		$vipnom = new Zend_Form_Element_Text('nomVip');
		$vipnom	->setLabel('Nom* :')
				->addFilter('StripTags')
				->addFilter('StringToLower')
				->addValidator('StringLength', false,array(3 ,20))
				->addValidator('alnum')
				->addValidator('regex', false, array('/^[a-z]+/'))
				->addFilter('StringTrim')
				->setRequired(true);
		$this->addElement($vipnom);
		
//prenom		
		$vipprenom = new Zend_Form_Element_Text('prenomVip');
		$vipprenom	->setLabel('Prenom* :')
				->addFilter('StripTags')
				->addFilter('StringToLower')
				->addValidator('StringLength', false,array(3 ,20))
				->addValidator('alnum')
				->addValidator('regex', false, array('/^[a-z]+/'))
				->addFilter('StringTrim')
				->setRequired(true);
		$this->addElement($vipprenom);

//sex
		
		$vipsex = new Zend_Form_Element_Select('sexVip');
		$vipsex		->addMultiOptions(array(
				'm' => 'Masculin',
				'f' => 'Feminin'
			));
		
		$vipsex	->setLabel('Sexe :');
		$this->addElement($vipsex);
		
//date		
		$vipdate = new Zend_Form_Element_Text('dateVip');
		$vipdate	->setLabel('Date de naissance :')
					->setAttrib('placeholder','jj/mm/aaaa')
					->addFilter('StripTags')	
					->addValidator('StringLength', false,array(10 ,10))
					//->addValidator('regex', false, array('^(((((0[1-9])|(1\d)|(2[0-8]))\/((0[1-9])|(1[0-2])))|((31\/((0[13578])|(1[02])))|((29|30)\/((0[1,3-9])|(1[0-2])))))\/((20[0-9][0-9])|(19[0-9][0-9])))|((29\/02\/(19|20)(([02468][048])|([13579][26]))))$'))
					->addFilter('StringTrim');
		$this->addElement($vipdate);
		
//nationalite
		$vipnat = new Zend_Form_Element_Select('natVip');
		$vipnat		->setLabel("Nationalité :");
		$this->addElement($vipnat);
		
		
//commentaire

		$vipcom = new Zend_Form_Element_Textarea('comVip');
		$vipcom	->setLabel('Commentaire :')
				->setAttrib('cols','40')
				->setAttrib('rows','4');
		$this->addElement($vipcom);

//profession		
		$vipprof = new Zend_Form_Element_MultiCheckbox('profVip', array(
		    'multiOptions' => array(
		        'acteur' => 'Acteur',
		        'realisateur' => 'Réalisateur',
		        'chanteur' => 'Chanteur',
		        'mannequin' => 'Mannequin',
		        'couturier' => 'Couturier'
		    )
		));
		$vipprof->setLabel('Profession(s)* :');
		$this->addElement($vipprof);
//image		
		$vipimg = new Zend_Form_Element_File('imgVip');
		$vipimg	->setLabel('Selectionner image :')
		        ->setDestination('./images/photos');
		// Fait en sorte qu'il y ait un seul fichier
		$vipimg->addValidator('Count', false, 1);
		// limite � 5Mo
		$vipimg->addValidator('Size', false, 5120000);
		// seulement des JPEG, PNG, et GIFs
		$vipimg->addValidator('Extension', false, 'jpg,png,gif');
		$this->addElement($vipimg, 'imgVip');
		
		$this->setAttrib('enctype', 'multipart/form-data');
//img sujet				
		$vipimgsujet = new Zend_Form_Element_Text('imgsujetVip');
		$vipimgsujet	->setLabel('Sujet :')
				->addFilter('StripTags')
				->addValidator('StringLength', false,array(0 ,220))
				->addFilter('StringTrim');
		$this->addElement($vipimgsujet);
//img commentaire
		$vipimgcom = new Zend_Form_Element_Text('imgcomVip');
		$vipimgcom	->setLabel('Commentaire :')
				->addFilter('StripTags')
				->addValidator('StringLength', false,array(0 ,250))
				->addFilter('StringTrim');
		$this->addElement($vipimgcom);
//vip mariage				
		$vipmari = new Zend_Form_Element_Select('vipmariVip');
		$vipmari ->setLabel("Mariage actuel :")
				 ->addMultiOptions(array('0' =>'Selectionner le Vip'))
				 ->setValue('0');				
		$this->addElement($vipmari);
		
		
//date mariage		
		$vipdatemari = new Zend_Form_Element_Text('datemariVip');
		$vipdatemari	->setLabel('Date :')
					->setAttrib('placeholder','jj/mm/aaaa')
					->addFilter('StripTags')	
					->addValidator('StringLength', false,array(10 ,10))
					//->addValidator('regex', false, array('^(((((0[1-9])|(1\d)|(2[0-8]))\/((0[1-9])|(1[0-2])))|((31\/((0[13578])|(1[02])))|((29|30)\/((0[1,3-9])|(1[0-2])))))\/((20[0-9][0-9])|(19[0-9][0-9])))|((29\/02\/(19|20)(([02468][048])|([13579][26]))))$'))
					->addFilter('StringTrim');
		$this->addElement($vipdatemari);
		
//date fin mariage		
		$vipdatefinmari = new Zend_Form_Element_Text('datefinmariVip');
		$vipdatefinmari	->setLabel('Date de fin du mariage :')
					->setAttrib('placeholder','jj/mm/aaaa')
					->addFilter('StripTags')	
					->addValidator('StringLength', false,array(10 ,10))
					//->addValidator('regex', false, array('^(((((0[1-9])|(1\d)|(2[0-8]))\/((0[1-9])|(1[0-2])))|((31\/((0[13578])|(1[02])))|((29|30)\/((0[1,3-9])|(1[0-2])))))\/((20[0-9][0-9])|(19[0-9][0-9])))|((29\/02\/(19|20)(([02468][048])|([13579][26]))))$'))
					->addFilter('StringTrim');
		$this->addElement($vipdatefinmari);
		
		
//vip liaison		
		$vipliai = new Zend_Form_Element_Select('vipliaiVip');
		$vipliai ->setLabel("Liaison actuel :")
				 ->addMultiOptions(array('0' =>'Selectionner le Vip'))
				 ->setValue('0');
		$this->addElement($vipliai);
				
//date		liaison
		$vipdateliai = new Zend_Form_Element_Text('dateliaiVip');
		$vipdateliai	->setLabel('Date :')
					->setAttrib('placeholder','jj/mm/aaaa')
					->addFilter('StripTags')	
					->addValidator('StringLength', false,array(10 ,10))
					//->addValidator('regex', false, array('^(((((0[1-9])|(1\d)|(2[0-8]))\/((0[1-9])|(1[0-2])))|((31\/((0[13578])|(1[02])))|((29|30)\/((0[1,3-9])|(1[0-2])))))\/((20[0-9][0-9])|(19[0-9][0-9])))|((29\/02\/(19|20)(([02468][048])|([13579][26]))))$'))
					->addFilter('StringTrim');
		$this->addElement($vipdateliai);	
		
		
//liaison motif				
		$vipliaimotif = new Zend_Form_Element_Text('liaimotifVip');
		$vipliaimotif	->setLabel('Motif :')
				->addFilter('StripTags')
				->addValidator('StringLength', false,array(0 ,220))
				->addFilter('StringTrim');
		$this->addElement($vipliaimotif);
				
		$submitButton = new Zend_Form_Element_Submit('Valider');
		$this->addElement($submitButton); 
		
		$resetButton = new Zend_Form_Element_Reset('Annuler');
		$this->addElement($resetButton);
		
		
	}
	public function remplirNat($resu){
		foreach ($resu as $ligne){
			$this->natVip->addMultiOption($ligne->NATIONALITE_NUMERO , $ligne->NATIONALITE_NOM);
		}
	}
	public function remplirVip($resu){
		foreach ($resu as $ligne){
			$this->vipmariVip->addMultiOption($ligne->VIP_NUMERO, $ligne->VIP_NOM);
			$this->vipliaiVip->addMultiOption($ligne->VIP_NUMERO, $ligne->VIP_NOM);
			
		}
	}
	
}



?>